<?php
	require "../database/mysql.class.php";
class alldao{	
	private $db;
	public function __construct(){
		$this->db=new mysql();
	}
	//赛事查询
	public function saishi(){
		$sql="select  id, img from saishi;";
		return $this->db->query($sql);		
	}
	//关卡查询
	public function mission($simg,$userid){
		$sql="select m.img mimg,m.mlevel mle,m.playmap mpm,m.id mid,m.jinbi mjb,um.misionid misionid 
		 from (select * from saiduan where simg='".$simg."') m left join
				 (select * from user_mission WHERE userid=".$userid." )um on m.id=um.misionid;";
		return $this->db->query($sql);		
	} 
	//公告查询
	public function gongao(){
		$sql="select  message,img from gongao order by time desc limit 0,1;";
		return $this->db->query($sql);	
	}
	//查询商店车手
	public function shoprider($userid){
		$sql="select r.id rid,r.price rp,r.rname rn,r.img ri,ur.riderid riderid from ridegamer r left join (select * from user_rider WHERE userid=".$userid.") ur on r.id=ur.riderid;";
		return $this->db->query($sql);		
	}
	//查询商店车辆
	public function shopbike($userid){
		$sql="select r.id rid,r.price rp,r.bname rn,r.img ri, ub.bikeid bikeid from  bikes r left join (select * from user_bike WHERE userid=".$userid.") ub  on r.id=ub.bikeid;";
		return $this->db->query($sql);		
	}
	//查询商店装备
	public function shopequip($userid){
		$sql="select r.id rid,r.price rp,r.ename rn,r.img ri,ue.equipid equipid from equgamer r left join (select * from user_equip WHERE userid=".$userid.") ue  on r.id=ue.equipid;";
		return $this->db->query($sql);		
	}
	//充值接口查询
	public function chongzhi(){
		$sql="select  jiekou  from chzhijk ;";
		return $this->db->query($sql);	
	}
	//充值订单
	public function Chongding($uname,$val,$jiekou){
		$sql="INSERT INTO chzhi  VALUES(null,'".$uname."',".$val.",'".$jiekou."',now());";
		return $this->db->insert($sql);
	}
}







?>